/*
 * Amazon Ads API - Sponsored Products
 * Use the Amazon Ads API for Sponsored Products for campaign, ad group, keyword, negative keyword, and product ad management operations. For more information about Sponsored Products, see the [Sponsored Products Support Center](https://advertising.amazon.com/help?entityId=ENTITY3CWETCZD9HEG2#GWGFKPEWVWG2CLUJ). For onboarding information, see the [account setup](setting-up/account-setup) topic.<br/><br/> 
 *
 * The version of the OpenAPI document: 2.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package org.openapitools.client.api;

import org.openapitools.client.ApiCallback;
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.ApiResponse;
import org.openapitools.client.Configuration;
import org.openapitools.client.Pair;
import org.openapitools.client.ProgressRequestBody;
import org.openapitools.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import org.openapitools.client.model.Error;
import org.openapitools.client.model.InlineResponse2001;
import org.openapitools.client.model.InlineResponse2002;
import org.openapitools.client.model.Report;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReportsApi {
    private ApiClient localVarApiClient;

    public ReportsApi() {
        this(Configuration.getDefaultApiClient());
    }

    public ReportsApi(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return localVarApiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    /**
     * Build call for downloadReport
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The identifier of the requested report. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 307 </td><td> Successful operation. </td><td>  * Location - Redirect URI with S3 file location containing report data <br>  </td></tr>
        <tr><td> 400 </td><td> Bad request. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not found - requested resource does not exist or is not visible for the authenticated user. </td><td>  -  </td></tr>
        <tr><td> 429 </td><td> Too many requests - request was rate-limited. Retry later. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal server error - something went wrong on the server. Retry later and report an error if unresolved. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call downloadReportCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/reports/{reportId}/download"
            .replaceAll("\\{" + "reportId" + "\\}", localVarApiClient.escapeString(reportId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call downloadReportValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling downloadReport(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling downloadReport(Async)");
        }
        
        // verify the required parameter 'reportId' is set
        if (reportId == null) {
            throw new ApiException("Missing the required parameter 'reportId' when calling downloadReport(Async)");
        }
        

        okhttp3.Call localVarCall = downloadReportCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId, _callback);
        return localVarCall;

    }

    /**
     * Downloads a previously requested report identified by report ID.
     * Gets a &#x60;307 Temporary Redirect&#x60; response that includes a &#x60;location&#x60; header with the value set to an AWS S3 path where the report is located. The path expires after 30 seconds. If the path expires before the report is downloaded, a new report request must be created.   The report file contains one row per entity for which performance data is present. These records are represented as JSON containing the ID attribute corresponding to the &#x60;recordType&#x60;, the segment (if specified), and each of the metrics in the request.  **Note**: The report files in S3 are gzipped.  *Example report download*  &#x60;&#x60;&#x60; $ curl -o /tmp/report.json.gz \&quot;https://sandboxreports.s3.amazonaws.com/amzn1.clicksAPI.v1.m1.xxxxxxx.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx?AWSAccessKeyId&#x3D;XXXXXXXXXXXXXXX&amp;amp;Expires&#x3D;1476479900&amp;amp;Signature&#x3D;xxxxxxxxxxxxxxxxxxxx\&quot; &#x60;&#x60;&#x60;  **To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).**
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The identifier of the requested report. (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 307 </td><td> Successful operation. </td><td>  * Location - Redirect URI with S3 file location containing report data <br>  </td></tr>
        <tr><td> 400 </td><td> Bad request. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not found - requested resource does not exist or is not visible for the authenticated user. </td><td>  -  </td></tr>
        <tr><td> 429 </td><td> Too many requests - request was rate-limited. Retry later. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal server error - something went wrong on the server. Retry later and report an error if unresolved. </td><td>  -  </td></tr>
     </table>
     */
    public void downloadReport(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId) throws ApiException {
        downloadReportWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId);
    }

    /**
     * Downloads a previously requested report identified by report ID.
     * Gets a &#x60;307 Temporary Redirect&#x60; response that includes a &#x60;location&#x60; header with the value set to an AWS S3 path where the report is located. The path expires after 30 seconds. If the path expires before the report is downloaded, a new report request must be created.   The report file contains one row per entity for which performance data is present. These records are represented as JSON containing the ID attribute corresponding to the &#x60;recordType&#x60;, the segment (if specified), and each of the metrics in the request.  **Note**: The report files in S3 are gzipped.  *Example report download*  &#x60;&#x60;&#x60; $ curl -o /tmp/report.json.gz \&quot;https://sandboxreports.s3.amazonaws.com/amzn1.clicksAPI.v1.m1.xxxxxxx.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx?AWSAccessKeyId&#x3D;XXXXXXXXXXXXXXX&amp;amp;Expires&#x3D;1476479900&amp;amp;Signature&#x3D;xxxxxxxxxxxxxxxxxxxx\&quot; &#x60;&#x60;&#x60;  **To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).**
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The identifier of the requested report. (required)
     * @return ApiResponse&lt;Void&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 307 </td><td> Successful operation. </td><td>  * Location - Redirect URI with S3 file location containing report data <br>  </td></tr>
        <tr><td> 400 </td><td> Bad request. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not found - requested resource does not exist or is not visible for the authenticated user. </td><td>  -  </td></tr>
        <tr><td> 429 </td><td> Too many requests - request was rate-limited. Retry later. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal server error - something went wrong on the server. Retry later and report an error if unresolved. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Void> downloadReportWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId) throws ApiException {
        okhttp3.Call localVarCall = downloadReportValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId, null);
        return localVarApiClient.execute(localVarCall);
    }

    /**
     * Downloads a previously requested report identified by report ID. (asynchronously)
     * Gets a &#x60;307 Temporary Redirect&#x60; response that includes a &#x60;location&#x60; header with the value set to an AWS S3 path where the report is located. The path expires after 30 seconds. If the path expires before the report is downloaded, a new report request must be created.   The report file contains one row per entity for which performance data is present. These records are represented as JSON containing the ID attribute corresponding to the &#x60;recordType&#x60;, the segment (if specified), and each of the metrics in the request.  **Note**: The report files in S3 are gzipped.  *Example report download*  &#x60;&#x60;&#x60; $ curl -o /tmp/report.json.gz \&quot;https://sandboxreports.s3.amazonaws.com/amzn1.clicksAPI.v1.m1.xxxxxxx.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx?AWSAccessKeyId&#x3D;XXXXXXXXXXXXXXX&amp;amp;Expires&#x3D;1476479900&amp;amp;Signature&#x3D;xxxxxxxxxxxxxxxxxxxx\&quot; &#x60;&#x60;&#x60;  **To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).**
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The identifier of the requested report. (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 307 </td><td> Successful operation. </td><td>  * Location - Redirect URI with S3 file location containing report data <br>  </td></tr>
        <tr><td> 400 </td><td> Bad request. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not found - requested resource does not exist or is not visible for the authenticated user. </td><td>  -  </td></tr>
        <tr><td> 429 </td><td> Too many requests - request was rate-limited. Retry later. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal server error - something went wrong on the server. Retry later and report an error if unresolved. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call downloadReportAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId, final ApiCallback<Void> _callback) throws ApiException {

        okhttp3.Call localVarCall = downloadReportValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId, _callback);
        localVarApiClient.executeAsync(localVarCall, _callback);
        return localVarCall;
    }
    /**
     * Build call for getReport
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The report identifier. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getReportCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/reports/{reportId}"
            .replaceAll("\\{" + "reportId" + "\\}", localVarApiClient.escapeString(reportId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getReportValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling getReport(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling getReport(Async)");
        }
        
        // verify the required parameter 'reportId' is set
        if (reportId == null) {
            throw new ApiException("Missing the required parameter 'reportId' when calling getReport(Async)");
        }
        

        okhttp3.Call localVarCall = getReportCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId, _callback);
        return localVarCall;

    }

    /**
     * Gets a previously requested report specified by identifier.
     * To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The report identifier. (required)
     * @return InlineResponse2002
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public InlineResponse2002 getReport(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId) throws ApiException {
        ApiResponse<InlineResponse2002> localVarResp = getReportWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId);
        return localVarResp.getData();
    }

    /**
     * Gets a previously requested report specified by identifier.
     * To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The report identifier. (required)
     * @return ApiResponse&lt;InlineResponse2002&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<InlineResponse2002> getReportWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId) throws ApiException {
        okhttp3.Call localVarCall = getReportValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId, null);
        Type localVarReturnType = new TypeToken<InlineResponse2002>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Gets a previously requested report specified by identifier. (asynchronously)
     * To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param reportId The report identifier. (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getReportAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String reportId, final ApiCallback<InlineResponse2002> _callback) throws ApiException {

        okhttp3.Call localVarCall = getReportValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, reportId, _callback);
        Type localVarReturnType = new TypeToken<InlineResponse2002>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for requestReport
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param recordType The type of entity for which the report should be generated. (required)
     * @param report  (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 406 </td><td> One or more values specified for a parameter was not within the specified acceptable range. </td><td>  -  </td></tr>
        <tr><td> 422 </td><td> An invalid parameter was specified. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call requestReportCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String recordType, Report report, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = report;

        // create path and map variables
        String localVarPath = "/v2/sp/{recordType}/report"
            .replaceAll("\\{" + "recordType" + "\\}", localVarApiClient.escapeString(recordType.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call requestReportValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String recordType, Report report, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling requestReport(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling requestReport(Async)");
        }
        
        // verify the required parameter 'recordType' is set
        if (recordType == null) {
            throw new ApiException("Missing the required parameter 'recordType' when calling requestReport(Async)");
        }
        

        okhttp3.Call localVarCall = requestReportCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, recordType, report, _callback);
        return localVarCall;

    }

    /**
     * Requests a Sponsored Products report.
     * Requests the creation of a performance report for all entities of a single type which have performance data to report. Record types can be one of &#x60;campaigns&#x60;, &#x60;adGroups&#x60;, &#x60;keywords&#x60;, &#x60;productAds&#x60;, &#x60;asins&#x60;, and &#x60;targets&#x60;.   **To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).**  **Note**: &#x60;asins&#x60; reports currently can **not** include metrics associated with both keywords and targets. If the &#x60;targetingId&#x60; value is set in the request, the report filters on targets and does not return sales associated with keywords. If the &#x60;targetingId&#x60; value is **not** set in the request, the report filters on keywords and does not return sales associated with targets. Therefore, the default behavior filters the report on keywords. Also note that if both &#x60;keywordId&#x60; **and** &#x60;targetingId&#x60; values are passed, the report filters on targets only and does **not** return keywords.
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param recordType The type of entity for which the report should be generated. (required)
     * @param report  (optional)
     * @return InlineResponse2001
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 406 </td><td> One or more values specified for a parameter was not within the specified acceptable range. </td><td>  -  </td></tr>
        <tr><td> 422 </td><td> An invalid parameter was specified. </td><td>  -  </td></tr>
     </table>
     */
    public InlineResponse2001 requestReport(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String recordType, Report report) throws ApiException {
        ApiResponse<InlineResponse2001> localVarResp = requestReportWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, recordType, report);
        return localVarResp.getData();
    }

    /**
     * Requests a Sponsored Products report.
     * Requests the creation of a performance report for all entities of a single type which have performance data to report. Record types can be one of &#x60;campaigns&#x60;, &#x60;adGroups&#x60;, &#x60;keywords&#x60;, &#x60;productAds&#x60;, &#x60;asins&#x60;, and &#x60;targets&#x60;.   **To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).**  **Note**: &#x60;asins&#x60; reports currently can **not** include metrics associated with both keywords and targets. If the &#x60;targetingId&#x60; value is set in the request, the report filters on targets and does not return sales associated with keywords. If the &#x60;targetingId&#x60; value is **not** set in the request, the report filters on keywords and does not return sales associated with targets. Therefore, the default behavior filters the report on keywords. Also note that if both &#x60;keywordId&#x60; **and** &#x60;targetingId&#x60; values are passed, the report filters on targets only and does **not** return keywords.
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param recordType The type of entity for which the report should be generated. (required)
     * @param report  (optional)
     * @return ApiResponse&lt;InlineResponse2001&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 406 </td><td> One or more values specified for a parameter was not within the specified acceptable range. </td><td>  -  </td></tr>
        <tr><td> 422 </td><td> An invalid parameter was specified. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<InlineResponse2001> requestReportWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String recordType, Report report) throws ApiException {
        okhttp3.Call localVarCall = requestReportValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, recordType, report, null);
        Type localVarReturnType = new TypeToken<InlineResponse2001>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Requests a Sponsored Products report. (asynchronously)
     * Requests the creation of a performance report for all entities of a single type which have performance data to report. Record types can be one of &#x60;campaigns&#x60;, &#x60;adGroups&#x60;, &#x60;keywords&#x60;, &#x60;productAds&#x60;, &#x60;asins&#x60;, and &#x60;targets&#x60;.   **To understand the call flow for asynchronous reports, see [Getting started with sponsored ads reports](/API/docs/en-us/concepts/reporting/sponsored-ads).**  **Note**: &#x60;asins&#x60; reports currently can **not** include metrics associated with both keywords and targets. If the &#x60;targetingId&#x60; value is set in the request, the report filters on targets and does not return sales associated with keywords. If the &#x60;targetingId&#x60; value is **not** set in the request, the report filters on keywords and does not return sales associated with targets. Therefore, the default behavior filters the report on keywords. Also note that if both &#x60;keywordId&#x60; **and** &#x60;targetingId&#x60; values are passed, the report filters on targets only and does **not** return keywords.
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param recordType The type of entity for which the report should be generated. (required)
     * @param report  (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 406 </td><td> One or more values specified for a parameter was not within the specified acceptable range. </td><td>  -  </td></tr>
        <tr><td> 422 </td><td> An invalid parameter was specified. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call requestReportAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String recordType, Report report, final ApiCallback<InlineResponse2001> _callback) throws ApiException {

        okhttp3.Call localVarCall = requestReportValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, recordType, report, _callback);
        Type localVarReturnType = new TypeToken<InlineResponse2001>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
